const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
  configureWebpack: config => {
    if (process.env.NODE_ENV === "production") {
      config.plugins.push(
        new UglifyJsPlugin({
          uglifyOptions: {
            warnings: false,
            compress: {
              drop_debugger: true, // console
              drop_console: false,
              pure_funcs: ["console.log"] // 移除console
            }
          },
          sourceMap: true,
          parallel: false
        })
      );
    }
  },
  publicPath: "./", // 基本路径
  outputDir: "dist", // 输出文件目录
  lintOnSave: true,  // eslint 验证
  devServer: {
    // proxy: {
    //   '/': {
    //       target: 'https://test-demo.chemistwarehouse.cn', //API服务器的地址
    //       changeOrigin: true, // 虚拟的站点需要更管origin
    //   }
    // },
    port: process.env.PORT || 8090 // 端口
  },
  productionSourceMap: false
};
